<?php

namespace app\api\controller;

use app\common\controller\Api;
use app\common\model\Config as ConfigModel;
/**
 * 招工首页接口
 */
class Work extends Api
{
    protected $noNeedLogin = [''];
    protected $noNeedRight = ['*'];

    /**
     * 首页
     *
     */
    public function index()
    {   
        //用户id
        $user = $this->auth->getUserinfo();
        $user_id=$user['id'];
        $page = input('page')?input('page'):1;
        $limit = input('limit')?input('limit'):10;
        $newcity=input('newcity');
        if(empty($newcity)){
            $this->error('城市不能为空');
        }
        $newcity=rtrim($newcity,"市");
        //搜索
        $search=input('search')?input('search'):'';
        $info=db('User')->field('id,type')->where(['id'=>$user_id])->find();
        if(empty($info)){
            $this->error('暂无数据');
        }
        
        //显示工作信息
        if($info['type']==1){
            //拼接where条件
            $where['address']=array('like',"%".$newcity."%");//城市
            $where['title']=array('like',"%".$search."%");//招工标题
            $where['status'] = 1;
            $work=input('work')?input('work'):''; //工种:1=结构,2=管道,3=纯水,4=电工
            $level=input('level')?input('level'):'';//级别:1=小工,2=中工,3=大工,4=带班

            if (preg_match('/小工/',$search)) {
                $level=1;
            }
            if (preg_match('/中工/',$search)) {
                $level=2;
            }
            if (preg_match('/大工/',$search)) {
                $level=3;
            }
            if (preg_match('/带班/',$search)) {
                $level=4;
            }
             if (preg_match('/结构/',$search)) {
                $work=1;
            }
            if (preg_match('/管道/',$search)) {
                $work=2;
            }
            if (preg_match('/纯水/',$search)) {
                $work=3;
            }
            if (preg_match('/电工/',$search)) {
                $work=4;
            }
            if($work && $level){
                if($work==1){
                    $str = 'jgg';
                }
                if($work==2){
                    $str = 'fgg';
                }
                if($work==3){
                    $str = 'cs';
                }
                if($work==4){
                    $str = 'dg';
                }
                if($level==1){
                    $str1 = 'xg';
                }
                if($level==2){
                    $str1 = 'zg';
                }
                if($level==3){
                    $str1 = 'dg';
                }
                if($level==4){
                    $str1 = 'db';
                }
                $where[$str.'_'.$str1.'_num'] = ['neq',0];
                $list=db('Work')->where($where)->page($page,$limit)->select();

            }

            if($work=='' && $level){
                if($level==1){
                    $str1 = 'xg';
                }
                if($level==2){
                    $str1 = 'zg';
                }
                if($level==3){
                    $str1 = 'dg';
                }
                if($level==4){
                    $str1 = 'db';
                }
                $whereOr['jgg'.'_'.$str1.'_num'] = ['neq',0];
                $whereOr['fgg'.'_'.$str1.'_num'] = ['neq',0];
                $whereOr['cs'.'_'.$str1.'_num'] = ['neq',0];
                $whereOr['dg'.'_'.$str1.'_num'] = ['neq',0];
                $list=db('Work')->where($where)->where(function ($q) use($whereOr) {
                    $q->whereOr($whereOr);
                })->page($page,$limit)->select();
            }

            if($work && $level==''){
               if($work==1){
                    $str = 'jgg';
                }
                if($work==2){
                    $str = 'fgg';
                }
                if($work==3){
                    $str = 'cs';
                }
                if($work==4){
                    $str = 'dg';
                }
                $whereOr[$str.'_'.'xg'.'_num'] = ['neq',0];
                $whereOr[$str.'_'.'zg'.'_num'] = ['neq',0];
                $whereOr[$str.'_'.'dg'.'_num'] = ['neq',0];
                $whereOr[$str.'_'.'db'.'_num'] = ['neq',0];
                $list=db('Work')->where($where)->where(function ($q) use($whereOr) {
                    $q->whereOr($whereOr);
                })->page($page,$limit)->select();
            }
           // var_dump($list);
           // die;
           if ($work=='' && $level=='') {
               $list=db('Work')->where($where)->page($page,$limit)->select();
           }
            
            foreach ($list as $k => $v) {
                //查询工作已招人数
                $where9['work_id']=$v['id'];
                $where9['user_id']=$v['user_id'];
                $where9['status']=2;
                //结构
                $where3['work']=1;//工种:1=结构,2=管道,3=纯水,4=电工
                $where3['level']=1;//级别:1=小工,2=中工,3=大工,4=带班
                $j_xiao=db('findwork')->where($where9)->where($where3)->count();
                $where4['work']=1;//工种:1=结构,2=管道,3=纯水,4=电工
                $where4['level']=2;//级别:1=小工,2=中工,3=大工,4=带班
                $j_zhong=db('findwork')->where($where9)->where($where4)->count();
                $where5['work']=1;//工种:1=结构,2=管道,3=纯水,4=电工
                $where5['level']=3;//级别:1=小工,2=中工,3=大工,4=带班
                $j_da=db('findwork')->where($where9)->where($where5)->count();
                $where6['work']=1;//工种:1=结构,2=管道,3=纯水,4=电工
                $where6['level']=4;//级别:1=小工,2=中工,3=大工,4=带班
                $j_dai=db('findwork')->where($where9)->where($where6)->count();
                //管道
                $where1['work']=2;//工种:1=结构,2=管道,3=纯水,4=电工
                $where1['level']=1;//级别:1=小工,2=中工,3=大工,4=带班
                $g_xiao=db('findwork')->where($where9)->where($where1)->count();
                $where2['work']=2;//工种:1=结构,2=管道,3=纯水,4=电工
                $where2['level']=2;//级别:1=小工,2=中工,3=大工,4=带班
                $g_zhong=db('findwork')->where($where9)->where($where2)->count();
                $where11['work']=2;//工种:1=结构,2=管道,3=纯水,4=电工
                $where11['level']=3;//级别:1=小工,2=中工,3=大工,4=带班
                $g_da=db('findwork')->where($where9)->where($where11)->count();
                $where12['work']=2;//工种:1=结构,2=管道,3=纯水,4=电工
                $where12['level']=4;//级别:1=小工,2=中工,3=大工,4=带班
                $g_dai=db('findwork')->where($where9)->where($where12)->count();
                //纯水
                $where13['work']=3;//工种:1=结构,2=管道,3=纯水,4=电工
                $where13['level']=1;//级别:1=小工,2=中工,3=大工,4=带班
                $c_xiao=db('findwork')->where($where9)->where($where13)->count();
                $where14['work']=3;//工种:1=结构,2=管道,3=纯水,4=电工
                $where14['level']=2;//级别:1=小工,2=中工,3=大工,4=带班
                $c_zhong=db('findwork')->where($where9)->where($where14)->count();
                $where15['work']=3;//工种:1=结构,2=管道,3=纯水,4=电工
                $where15['level']=3;//级别:1=小工,2=中工,3=大工,4=带班
                $c_da=db('findwork')->where($where9)->where($where15)->count();
                $where16['work']=3;//工种:1=结构,2=管道,3=纯水,4=电工
                $where16['level']=4;//级别:1=小工,2=中工,3=大工,4=带班
                $c_dai=db('findwork')->where($where9)->where($where16)->count();
                //电工
                $where17['work']=4;//工种:1=结构,2=管道,3=纯水,4=电工
                $where17['level']=1;//级别:1=小工,2=中工,3=大工,4=带班
                $d_xiao=db('findwork')->where($where9)->where($where17)->count();
                $where18['work']=4;//工种:1=结构,2=管道,3=纯水,4=电工
                $where18['level']=2;//级别:1=小工,2=中工,3=大工,4=带班
                $d_zhong=db('findwork')->where($where9)->where($where18)->count();
                $where19['work']=4;//工种:1=结构,2=管道,3=纯水,4=电工
                $where19['level']=3;//级别:1=小工,2=中工,3=大工,4=带班
                $d_da=db('findwork')->where($where9)->where($where19)->count();
                $where20['work']=4;//工种:1=结构,2=管道,3=纯水,4=电工
                $where20['level']=4;//级别:1=小工,2=中工,3=大工,4=带班
                $d_dai=db('findwork')->where($where9)->where($where20)->count();

                $boss=db('User')->field('id,username,phone,mobile')->where(['id'=>$v['user_id']])->find();//工头信息
                $list[$k]['username']=$boss['username'];
                $list[$k]['j_xiao']='　'.$j_xiao;
                $list[$k]['j_zhong']=$j_zhong;
                $list[$k]['j_da']=$j_da;
                $list[$k]['j_dai']=$j_dai;
                $list[$k]['c_xiao']='　'.$c_xiao;
                $list[$k]['c_zhong']=$c_zhong;
                $list[$k]['c_da']=$c_da;
                $list[$k]['c_dai']=$c_dai;
                $list[$k]['g_xiao']='　'.$g_xiao;
                $list[$k]['g_zhong']=$g_zhong;
                $list[$k]['g_da']=$g_da;
                $list[$k]['g_dai']=$g_dai;
                $list[$k]['d_xiao']='　'.$d_xiao;
                $list[$k]['d_zhong']=$d_zhong;
                $list[$k]['d_da']=$d_da;
                $list[$k]['d_dai']=$d_dai;        
                $list[$k]['phone']=$this->hidestr($boss['mobile'],3,4);
                $list[$k]['newphone']=$boss['mobile'];
              
                $list[$k]['createtime']=date('Y-m-d',$v['createtime']);
                $list[$k]['starttime']=date('Y/m/d',$v['starttime']);
            }
            
        }

        //显示工人信息
        if($info['type']==2){
            if (preg_match('/小工/',$search)) {
                $level=1;
            }
            if (preg_match('/中工/',$search)) {
                $level=2;
            }
            if (preg_match('/大工/',$search)) {
                $level=3;
            }
            if (preg_match('/带班/',$search)) {
                $level=4;
            }
             if (preg_match('/结构/',$search)) {
                $work=1;
            }
            if (preg_match('/管道/',$search)) {
                $work=2;
            }
            if (preg_match('/纯水/',$search)) {
                $work=3;
            }
            if (preg_match('/电工/',$search)) {
                $work=4;
            }
            //级别level
            $level=input('level');
            if ($level) {
                $where['level']=$level;
            }
            //工种
            $work=input('work');
            if ($work) {
                $where['work']=$work;
            }

            $where['type']=1;
            $where['state']=1;
            //拼接where条件
            $where['city']=array('like',"%".$newcity."%");
            $where['username']=array('like',"%".$search."%");//招工标题
            $list=db('User')->field('id,username,avatar,work,level,city,phone,mobile')->where($where)->page($page,$limit)->select();
            foreach ($list as $key => $value) {
                $list[$key]['username']=$this->hidestr($value['username'],1,2);
                //查询工作状态
                $where2['state']=array('neq',2);
                $where2['worker_id']=$value['id'];
                $findwork=db('Findwork')->where($where2)->find();
                if($findwork){
                    $list[$key]['state']='待';
                }
                $list[$key]['phone']=$this->hidestr($value['mobile'],3,4);
                $list[$key]['newphone']=$value['mobile'];
                //工种:1=结构,2=管道,3=纯水,4=电工
                if($value['work']==1){
                    $list[$key]['work']='结构';
                }
                if($value['work']==2){
                    $list[$key]['work']='管道';
                }
                if($value['work']==3){
                    $list[$key]['work']='纯水';
                }
                if($value['work']==4){
                    $list[$key]['work']='电工';
                }
                //级别:1=小工,2=中工,3=大工,4=带班
                if($value['level']==1){
                    $list[$key]['level']='小工';
                }
                if($value['level']==2){
                    $list[$key]['level']='中工';
                }
                if($value['level']==3){
                    $list[$key]['level']='大工';
                }
                if($value['level']==4){
                    $list[$key]['level']='带班';
                }
            }
        }

        $this->success('查询成功',$list);
      
    }
    /**
     * 幻灯片
     */
    public function slide(){
        //幻灯片
        $slide=db('slide')->where(['data'=>1])->select();
        $this->success('查询成功',$slide);
    }
    /**
     * 
     * 隐藏方法
     * 
     */
    public function hidestr($string, $start = 0, $length = 0, $re = '*') {
        if (empty($string)) return false;
        $strarr = array();
        $mb_strlen = mb_strlen($string);
        while ($mb_strlen) {//循环把字符串变为数组
            $strarr[] = mb_substr($string, 0, 1, 'utf8');
            $string = mb_substr($string, 1, $mb_strlen, 'utf8');
            $mb_strlen = mb_strlen($string);
        }
        $strlen = count($strarr);
        $begin  = $start >= 0 ? $start : ($strlen - abs($start));
        $end    = $last   = $strlen - 1;
        if ($length > 0) {
            $end  = $begin + $length - 1;
        } elseif ($length < 0) {
            $end -= abs($length);
        }
        for ($i=$begin; $i<=$end; $i++) {
            $strarr[$i] = $re;
        }
        if ($begin >= $end || $begin >= $last || $end > $last) return false;
        return implode('', $strarr);
    }
    

     /**
     * 工人详情
     *
    */
   	public function workDetail(){
   		//用户id
        $user = $this->auth->getUserinfo();
        $user_id=$user['id'];
        $worker_id=input('worker_id');//点击查看用户id
        $where['id']=$worker_id;
        // $where['state']=1;
        $list=db('User')->field('id,username,avatar,type,work,level,state,province,city,address,mobile')->where($where)->find();
        if (empty($list)) {
        	$this->error('暂无此用户数据');
        }
        //判断手机号是否填写 没有默认账号手机号
        $list['phone']=$list['mobile'];
        //查看当前用户否收藏
        $where1['user_id']=$user_id;
        $where1['byuser_id']=$worker_id;
        $collect=db('Collection')->where($where1)->find();
        if($collect){
        	//echo 1;
        	$list['is_collect']=1;//已收藏
        }else{
        	//echo 2;
        	$list['is_collect']=2;//未收藏
        }
        //工种:1=结构,2=管道,3=纯水,4=电工
        if($list['work']==1){
        	$list['work']='结构';
        }
        if($list['work']==2){
        	$list['work']='管道';
        }
        if($list['work']==3){
        	$list['work']='纯水';
        }
        if($list['work']==4){
        	$list['work']='电工';
        }
        //级别:1=小工,2=中工,3=大工,4=带班
        if($list['level']==1){
        	$list['level']='小工';
        }
        if($list['level']==2){
        	$list['level']='中工';
        }
        if($list['level']==3){
        	$list['level']='大工';
        }
        if($list['level']==4){
        	$list['level']='带班';
        }
        $limit=input('limit')?input('limit'):10;
        $page=input('page')?input('page'):1;
        //评价列表
        $comment=db('Comments')->where(['fromuser_id'=>$worker_id])->order('addtime desc')->page($page,$limit)->select();
        foreach($comment as $k=>$v){
        	$comment[$k]['addtime']=date('Y年m月d日',$v['addtime']);
        	//评论用户信息
        	$newuser=db('User')->field('id,avatar,username')->where(['id'=>$v['user_id']])->find();
        	$comment[$k]['username']=$newuser['username'];
        	$comment[$k]['avatar']=$newuser['avatar'];
        }
        $list['comment']=$comment;
        $this->success('查询成功',$list);
   	}

    /**
     * 收藏,取消收藏
     *
    */
   	public function clickCollect(){
   		//用户id
        $user = $this->auth->getUserinfo();
        $user_id=$user['id'];
        //收藏用户的id
        $byuser_id=input('byuser_id');
        if (empty($byuser_id)) {
            $this->error('被收藏用户不能为空');
        }
        //工作
        $work_id=input('work_id');
        //类型 1=工人,2=工头
        $type=input('type');
        if (empty($type)) {
            $this->error('用户类型不能为空');
        }
        //查询有没有收藏
        $collect=db('Collection')->where(['user_id'=>$user_id,'byuser_id'=>$byuser_id,'type'=>$type])->find();
        if($type==1){
            if($collect){
                //取消收藏 删除数据库
                $row=db('Collection')->where(['user_id'=>$user_id,'byuser_id'=>$byuser_id,'type'=>$type])->delete();
                if($row ){
                    $r['state']=2;
                    $this->success('取消收藏',$r);
                }
            }
        }
       if($type==2){
            $work=db('Collection')->where(['user_id'=>$user_id,'work_id'=>$work_id,'type'=>$type])->find();
            if($work){
                //取消收藏 删除数据库
                $row1=db('Collection')->where(['user_id'=>$user_id,'byuser_id'=>$byuser_id,'work_id'=>$work_id,'type'=>$type])->delete();
                if($row1 ){
                    $r1['state']=2;
                    $this->success('取消收藏',$r1);
                }
            }
       }
        $data['user_id']=$user_id;
        $data['byuser_id']=$byuser_id;
        $data['work_id']=$work_id;
        $data['type']=$type;
        $data['addtime']=time();
        $row=db('Collection')->insert($data);
        if($row){
            $r['state']=1;
            $this->success('收藏成功',$r);
        }
        
   	}

    /**
     * 评论
     *
    */
    public function comment(){
        //用户id
        $user = $this->auth->getUserinfo();
        $user_id=$user['id']; 
        $fromuser_id=input('fromuser_id');
        if(empty($fromuser_id)){
            $this->error('被评论用户不能为空');
        }
        $content=input('content');
        if(empty($content)){
            $this->error('评论内容不能为空');
        }
        $data['user_id']=$user_id;
        $data['fromuser_id']=$fromuser_id;
        $data['content']=$content;
        $data['addtime']=time();
        $row=db('Comments')->insert($data);
        //评论成功增加成长值
        $growth=Config('site.growth');//成长值
        db('User')->where(['id'=>$user_id])->setInc('growth',$growth);
        $this->success('评论成功');
       
    }
    /**
     * 预支工作列表
     */
    public function newWork(){
        //用户id
        $user = $this->auth->getUserinfo();
        $user_id=$user['id'];
        $newuser= db('User')->field('type')->where(['id'=>$user_id])->find();
        if(empty($newuser)){
            $this->error('暂无数据');
        }
        $where['state']=2;
        if ($newuser['type']==1) {
            $where['worker_id']=$user_id;
            $list=db('findwork')->field('id,user_id,work_id,worker_id')->where($where)->select();
            if(!$list){
               $this->error('暂无数据');
            }
            foreach ($list as $k => $v) {
               $work=db('work')->field('id,title,user_id')->where(['id'=>$v['work_id']])->find();
               $list[$k]['title']=$work['title'];
            }
            
        }
        if ($newuser['type']==2) {
            $where['user_id']=$user_id;
            $list=db('findwork')->field('id,user_id,work_id,worker_id')->where($where)->select();
            //var_dump($list);
            //die;
            if(!$list){
               $this->error('暂无数据');
            }
            foreach ($list as $k => $v) {
                $work=db('work')->field('id,title,user_id')->where(['id'=>$v['work_id']])->find();
                $arr=db('user')->field('id,username')->where(['id'=>$v['worker_id']])->find();
                $list[$k]['title']=$work['title'];
                $list[$k]['username']=$arr['username'];
            }
          
        }
        $this->success('查询成功',$list);
       
    }
    /**
     * 拿到项目查工人
     */
    public function selectworker(){
        //用户id
        $user = $this->auth->getUserinfo();
        $user_id=$user['id'];
        $work_id = input('work_id')?input('work_id'):'';
        
        if($work_id){
            $where['work_id'] = $work_id;
        }
        $where['user_id'] = $user_id;
        $where['state'] = 2;
        $list = db('findwork')->field('id,work_id,user_id,worker_id')->where($where)->select();
        foreach($list as $k=>$v){
            $user = db('user')->where(['id'=>$v['worker_id']])->find();
            $list[$k]['username'] = $user['username'];
            $list[$k]['worker_id'] = $user['id'];
        }
        $this->success('查询成功',$list);

    }
    
    /**
     * 借支 / 预支
     */
    public function advance(){
        //用户id
        $user = $this->auth->getUserinfo();
        $user_id=$user['id'];
        $list=db('User')->field('type')->where(['id'=>$user_id])->find();
        if(!$list){
            $this->error('暂无数据');
        }
        //工人预支
        $work_id=input('work_id');
        if (!$work_id) {
            $this->error('请填写项目名称');
        }
        $money=input('money');
        if (!$money) {
            $this->error('请填写预支金额');
        }
        $addtime=input('addtime');
        if (!$addtime) {
            $this->error('请选择预支时间');
        }
        $note=input('note')?input('note'):'';
        $data['user_id']=$user_id;
        $data['work_id']=$work_id;
        $data['money']=$money;
        $data['addtime']=$addtime;
        $data['note']=$note;
        $data['createtime']=time();
        $findwork=db('findwork')->where(['work_id'=>$work_id])->find();
        if(!$findwork){
            $this->error('此工作暂无数据');
        }
        //工人预支
        if($list['type']==1){
            $data['boss_id']=$findwork['user_id'];
            $r= db('worker_advance')->insert($data);
        }
        //工头借支
        if($list['type']==2){
            //工人
            $worker_id=input('worker_id');
            if (!$worker_id) {
                $this->error('请填写工人');
            }
            $data['worker_id']=$worker_id;
            $r= db('boss_advance')->insert($data);
        }
        if($r){
            $this->success('操作成功');
        }else{
             $this->error('操作失败');
        }
       
    }
    /**
     *   
     * 老板借支记录
     */
    public function bossjielist(){
        //用户id
        $user = $this->auth->getUserinfo();
        $user_id=$user['id'];
        $list = db('boss_advance')->where(['user_id'=>$user_id])->order('createtime desc')->select();
        foreach($list as $k=>$v){
            $worker = db('user')->where(['id'=>$v['user_id']])->find();
            $work = db('work')->where(['id'=>$v['work_id']])->find();
            $list[$k]['username'] = $worker['username'];
            $list[$k]['title'] = $work['title'];
        }
        $this->success('查询成功',$list);
    }
    /**
     * 工人预支记录
     */
    public function workyulist(){
        //用户id
        $user = $this->auth->getUserinfo();
        $user_id=$user['id'];
        $list = db('worker_advance')->where(['user_id'=>$user_id])->order('createtime desc')->select();
        foreach($list as $k=>$v){
            $boss = db('user')->where(['id'=>$v['boss_id']])->find();
            $work = db('work')->where(['id'=>$v['work_id']])->find();
            $list[$k]['username'] = $boss['username'];
            $list[$k]['title'] = $work['title'];
        }
        $this->success('查询成功',$list);
    }
    /**
     * 工人未结工资
     */
    public function workweijie(){
        $user = $this->auth->getUserinfo();
        $user_id=$user['id'];
        //找正在进行中的项目
        $where['worker_id'] = $user_id;
        $where['state'] = 2;
        $list = db('findwork')->where($where)->order('maketime desc')->select();
        foreach($list as $k=>$v){
            $work = db('work')->where(['id'=>$v['work_id']])->find();
            $list[$k]['title'] = $work['title'];//工作名称
            //工时
            $work_time = db('worker_perform')->where(['user_id'=>$user_id,'work_id'=>$v['work_id']])->sum('status');
            $jia_time = db('worker_perform')->where(['user_id'=>$user_id,'work_id'=>$v['work_id']])->sum('add_day');
            $list[$k]['work_time'] = $work_time+$jia_time;
            $list[$k]['total'] = $v['money']*$list[$k]['work_time'];
            $yuzhi = db('worker_advance')->where(['user_id'=>$user_id,'work_id'=>$v['work_id']])->sum('money');
            $list[$k]['yuzhi'] = $yuzhi;
            $list[$k]['weijie'] = $list[$k]['total']-$yuzhi;

        }
        $this->success('查询成功',$list);
    }
    /**
     * 工头未结工资
     */
    public function bossweijie(){
        $user = $this->auth->getUserinfo();
        $user_id=$user['id'];
        //找正在进行中的员工
        $where['user_id'] = $user_id;
        $where['state'] = 2;
        $list = db('findwork')->where($where)->order('maketime desc')->select();
        foreach($list as $k=>$v){
            $work = db('work')->where(['id'=>$v['work_id']])->find();
            $list[$k]['title'] = $work['title'];//工作名称
            //工人信息
            $worker = db('user')->where(['id'=>$v['worker_id']])->find();
            //工时
            $work_time = db('boss_perform')->where(['user_id'=>$user_id,'worker_id'=>$v['worker_id'],'work_id'=>$v['work_id']])->sum('status');
            $jia_time = db('boss_perform')->where(['user_id'=>$user_id,'worker_id'=>$v['worker_id'],'work_id'=>$v['work_id']])->sum('add_day');
            $list[$k]['work_time'] = $work_time+$jia_time;
            $list[$k]['total'] = $v['money']*$list[$k]['work_time'];
            $yuzhi = db('boss_advance')->where(['user_id'=>$v['worker_id'],'work_id'=>$v['work_id']])->sum('money');
            $list[$k]['yuzhi'] = $yuzhi;
            $list[$k]['weijie'] = $list[$k]['total']-$yuzhi;

        }
        $this->success('查询成功',$list);
    }
}
